Skip to content

Use a Event-Driven model to speed up IDE (FIX #10214 #10235) #10249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from

Conversation

ricardojlrufino
Copy link
Contributor

Description

My strategy was to try to solve the problems with as little refactoring as possible, so it was essential
the creation of the project: eventbus4j. (All the good projects I found use annotations, and I didn't think it was cool ...)

PS: Some parts of the changes made to this 'PR' were discussed in detail at: #10214 , #10235 and mail list.

Design improvements:

It is now possible to decouple the methods, making it easier to maintain UI consistency, using specific actions / events:

  • Library Changes
  • Board Changes
  • Port Changes.
  • Etc..

However, it was little explored, and some design errors are still present, because as I said I tried to make as few changes as possible.

Performance improvements:

Many methods were called several times unnecessarily, some were quite costly and hindered the IDE responsiveness.

  • The IDE should open more faster, since:
    • The longer menus are now loaded in the background
    • Fixed to ignore invalid examples
    • Fixed to avoid scan libraries twice
    • Avoids scan sketchbook folder like node_modules (PENDING !!)
  • Selecting a Board, should be more responsive, as it now generates an event to load rescan libraries background
  • Change Serial port, is more responsive
  • Close Board Manager, is more responsive

In my environment it got 11s faster (but it depends a lot of the environment)

There are some proposals for improvements

  • Create specific events (such as :selecting the serial port, calls onBoardOrPortChange, can be specific)
  • The Base class is very large, it would be interesting to separate it into BaseMenus and BaseHandlers (for handleXXX methods)
  • The board configuration menus still need refactoring (as mentioned here: [IDE] Slow Startup - because of events trigged by 'boardsCustomMenus' #10214 (comment)) . The event system using debounce fixed this error.

Tests

PS: I don't know exactly how to write tests for Interface, I tried to run locally and many tests failed.
I wrote the tests for eventbus4j (basic and concurrency tests, etc.)

About Event system:

Here it simplifies the way of use:

  // Editor.java
  private void registerEventBus() {
    
    EventBus.register(this, UIEvents.BoardOrPortChange.class, event -> {
      onBoardOrPortChange();
    });

  }
  
  @Override
  public void dispose() {
    super.dispose();
    EventBus.unregisterHandlers(this);
    EventBus.notify(new UIEvents.EditorClosed());
  }

For more details see:
https://github.com/ricardojlrufino/eventbus4j

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you lint your code locally prior to submission?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes

@ricardojlrufino ricardojlrufino deleted the startup-fix1 branch May 21, 2020 16:59
@matthijskooijman
Copy link
Collaborator

What's your plan with this? You closed this PR, did you change your mind, or are you planning to resubmit a new PR? Would you like some review of this PR and/or the general idea already?

@ricardojlrufino
Copy link
Contributor Author

Yes, I'm working on it.
I saw that I had a lot of formatting problems, and garbage that I needed to remove ... and the tests were not passing.

@cmaglie
Copy link
Member

cmaglie commented May 25, 2020

Hi @ricardojlrufino may I ask you to put these two commits into a separate PR?

60f19a8 Avoid call rescanLibraries() twice #10228
c07719d fix call rescanLibraries() twice #10228

I think they are OK and could be merged independently and solve #10228 (also it would make this PR slightly simpler for you to work on)

@cmaglie
Copy link
Member

cmaglie commented May 25, 2020

I think I can cherry pick from your branch, will open a PR shortly.

@per1234 per1234 added Component: IDE The Arduino IDE feature request A request to make an enhancement (not a bug fix) Type: Duplicate Another item already exists for this topic labels Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE feature request A request to make an enhancement (not a bug fix) Type: Duplicate Another item already exists for this topic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants